﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace LMIS_Application
{
    public partial class DeleteBook : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnDelBook_Click(object sender, EventArgs e)
        {
            Book b = new Book();
            int outcome = b.delBook(Convert.ToInt32(tb_DB_bkID.Text));

            if (outcome == -1)
            {
                info.Text = "There are books in the inventory. You must delete them first manually!\nOr you can force delete.";
                btn_DB_ForceDelete.Visible = true;
            }
            else if(outcome == 0)
            {
                info.Text = "Book is not in the system. Maybed you typed book id wrong?";
            }
            else if (outcome == 1)
            {
                info.Text = "Book Deleted";
            }
        }

        protected void btn_DB_ForceDelete_Click(object sender, EventArgs e)
        {
            Book b = new Book();
            bool outcome = b.ForceDelBook(Convert.ToInt32(tb_DB_bkID.Text));

            if (outcome)
            {
                info.Text = "Books are deleted!";
                btn_DB_ForceDelete.Visible = false;
            }
            else
            {
                info.Text = "Book not deleted. Try manually deleting each book in inventory";
                btn_DB_ForceDelete.Visible = false;
            }
        }
    }
}
